<?php

/**
 * DookhItem filter form base class.
 *
 * @package    dookh
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseDookhItemFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'user_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => true)),
      'category_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Category'), 'add_empty' => true)),
      'quality'       => new sfWidgetFormChoice(array('choices' => array('' => '', 'old' => 'old', 'new' => 'new', 'reconditioned' => 'reconditioned'))),
      'item_status'   => new sfWidgetFormChoice(array('choices' => array('' => '', 'in stock' => 'in stock', 'out stock' => 'out stock', 'just come' => 'just come'))),
      'status'        => new sfWidgetFormDoctrineChoice(array('choices' => array('' => '', 'approved' => 'approved', 'rejected' => 'rejected', 'pending' => 'pending'), 'model' => $this->getRelatedModelName('Abuse'), 'add_empty' => true)),
      'name'          => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'location'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'number_views'  => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'number_points' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'number_raters' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'price'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'image'         => new sfWidgetFormFilterInput(),
      'description'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'is_activated'  => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'expires_at'    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'is_featured'   => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'created_at'    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'slug'          => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'user_id'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('User'), 'column' => 'id')),
      'category_id'   => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Category'), 'column' => 'id')),
      'quality'       => new sfValidatorChoice(array('required' => false, 'choices' => array('old' => 'old', 'new' => 'new', 'reconditioned' => 'reconditioned'))),
      'item_status'   => new sfValidatorChoice(array('required' => false, 'choices' => array('in stock' => 'in stock', 'out stock' => 'out stock', 'just come' => 'just come'))),
      'status'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Abuse'), 'column' => 'id')),
      'name'          => new sfValidatorPass(array('required' => false)),
      'location'      => new sfValidatorPass(array('required' => false)),
      'number_views'  => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'number_points' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'number_raters' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'price'         => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'image'         => new sfValidatorPass(array('required' => false)),
      'description'   => new sfValidatorPass(array('required' => false)),
      'is_activated'  => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'expires_at'    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'is_featured'   => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'created_at'    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'slug'          => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('dookh_item_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'DookhItem';
  }

  public function getFields()
  {
    return array(
      'id'            => 'Number',
      'user_id'       => 'ForeignKey',
      'category_id'   => 'ForeignKey',
      'quality'       => 'Enum',
      'item_status'   => 'Enum',
      'status'        => 'ForeignKey',
      'name'          => 'Text',
      'location'      => 'Text',
      'number_views'  => 'Number',
      'number_points' => 'Number',
      'number_raters' => 'Number',
      'price'         => 'Number',
      'image'         => 'Text',
      'description'   => 'Text',
      'is_activated'  => 'Boolean',
      'expires_at'    => 'Date',
      'is_featured'   => 'Boolean',
      'created_at'    => 'Date',
      'updated_at'    => 'Date',
      'slug'          => 'Text',
    );
  }
}
